load("@local_config//:variables.bzl", "STATE_MACHINE_DEFAULT_COPTS")
load("@local_config//:bazel_info.bzl", "BAZEL_OUTPUT_BASE")
load("@com_grail_compdb//:aspects.bzl", "compilation_database")
load("//lint:macros.bzl", "lint_sources")

cc_binary(
    name = "simple1",
    srcs = ["simple1/main.cc"],
    copts = STATE_MACHINE_DEFAULT_COPTS,
    deps = ["//:state_machine"],
)

cc_binary(
    name = "simple2",
    srcs = ["simple2/main.cc"],
    copts = STATE_MACHINE_DEFAULT_COPTS,
    deps = ["//:state_machine"],
)

compilation_database(
    name = "compdb",
    targets = [
        ":simple1",
        ":simple2",
    ],
    exec_root = BAZEL_OUTPUT_BASE + "execroot/__main__",
)

lint_sources(
    name = "lint",
    sources = glob(["**/*.cc"]),
    compdb = ":compdb",
    dependencies = ["//:state_machine"],
    options = (
        "-checks=\""
        + "-bugprone-exception-escape,"
        + "-cppcoreguidelines-interfaces-global-init,"
        + "-cppcoreguidelines-pro-bounds-array-to-pointer-decay,"
        + "-fuchsia-statically-constructed-objects,"
        + "-hicpp-no-array-decay,"
        + "-misc-non-private-member-variables-in-classes,"
        + "-readability-convert-member-functions-to-static,"
        + "\""
    ),
)
